package com.it.sun.esaychat.user.vo;

import com.baomidou.mybatisplus.annotation.TableField;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.it.sun.esaychat.user.entity.UserEntity;
import lombok.*;
import org.springframework.security.core.GrantedAuthority;
import org.springframework.security.core.userdetails.UserDetails;

import java.time.LocalDateTime;
import java.util.Collection;
import java.util.Set;

/**
 * @author sunmannian
 * @ClassName com.it.sun.esaychat.user.vo.User
 * @Date 2020/6/13 15:19
 * @Version V1.0
 * Description  <请输入一句话描述该类功能>
 * Copyright (C) 北京中电兴发科技有限公司  since 2020/6/13
 */
@Data
@Builder
@EqualsAndHashCode(callSuper = true)
public class User extends UserEntity implements UserDetails {

    @TableField(exist = false)
    private Set<GrantedAuthority> authorities;

    @JsonIgnore
    @TableField(exist = false)
    private boolean accountNonExpired;

    @JsonIgnore
    @TableField(exist = false)
    private boolean accountNonLocked;

    @JsonIgnore
    @TableField(exist = false)
    private boolean credentialsNonExpired;

    @JsonIgnore
    @TableField(exist = false)
    private boolean enabled;

    @Override
    public Collection<? extends GrantedAuthority> getAuthorities() {
        return authorities;
    }

    @Override
    public boolean isAccountNonExpired() {
        return accountNonExpired;
    }

    @Override
    public boolean isAccountNonLocked() {
        return accountNonLocked;
    }

    @Override
    public boolean isCredentialsNonExpired() {
        return credentialsNonExpired;
    }

    @Override
    public boolean isEnabled() {
        return enabled;
    }

}
